package com.yy.device.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * 设备数据字节枚举
 *
 * @author sunzhiqiang
 * @date 2022/6/21 15:18:50
 */
public enum DeviceHeadEnum {
    /*开关-打开*/
    REGISTER_TASK(0xAA),
    /*开关-关闭*/
    REPORT(0xBB),
    /*读取*/
    HEART(0xCC);

    @Getter
    private final int type;

    DeviceHeadEnum(int type) {
        this.type = type;
    }

    public static DeviceHeadEnum getEnumByType(int type) {
        return Arrays.stream(DeviceHeadEnum.values())
                .filter(item -> item.getType() == type)
                .findFirst()
                .orElse(null);
    }
}
